﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class TargetCamera : Camera
    {
        public Vector3 Position { get; set; }
        public Vector3 Target { get; set; }

        public TargetCamera(Vector3 Position, Vector3 Target, GraphicsDevice graphicsDevice)
            : base(graphicsDevice)
        {
            this.Position = Position;
            this.Target = Target;
        }

        public override void Update()
        {// a camera precisa saber o que é frente, o que é lado, o que é cima
            Vector3 forward = Target - Position;// frente de visão da camera
            Vector3 side = Vector3.Cross(forward, Vector3.Down);// lado de visão da camera
            Vector3 up = Vector3.Cross(forward, side); // visão "cima" da camera
            this.View = Matrix.CreateLookAt(Position, Target, up);
        }
    }
}
